﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace ElegyPlayground
{
    public class InputController
    {
        //private Keyboard m_keyBoard;

        private KeyboardState m_oldState;

        public InputController()
        {
            m_oldState = Keyboard.GetState();
        }

        public Vector2 SetMovement(Vector2 movement)
        {
            var m_currentState = Microsoft.Xna.Framework.Input.Keyboard.GetState();
            if (m_oldState.IsKeyUp(Keys.Space) && m_currentState.IsKeyDown(Keys.Space))
            {
                    movement.Y = -100;
            }
            if (m_currentState.IsKeyDown(Keys.Left))
            {
                movement.X = -30;
            }
            if (m_currentState.IsKeyDown(Keys.Right))
            {
                movement.X = 30;
            }
            else if (m_currentState.IsKeyUp(Keys.Left) && m_currentState.IsKeyUp(Keys.Right))
            {
                movement.X = 0;
            }
            
            m_oldState = m_currentState;
            return movement;
        }
    }
}
